import path from "path";
import { Config } from "./components/index.js";

const _path = process.cwd() + "/plugins/xiaoyue-plugin";

export function supportGuoba() {
  return {
    pluginInfo: {
      name: 'xiaoyue-plugin',
      title: 'xiaoyue-plugin',
      author: '@云溪院',
      authorLink: 'https://gitee.com/yunxiyuan',
      link: 'https://gitee.com/yunxiyuan/xiaoyue-plugin',
      isV3: true,
      isV2: false,
      description: '云溪院涩涩插件,插件安装等,开车需谨慎!请谨慎驾驶',
      iconPath: path.join(_path, "resources/admin/logo.ico"),
    },
    // 配置项信息
    configInfo: {
      // 配置项 schemas
      schemas: [{
        field: 'yxy',
        label: '云溪院涩图功能',
        bottomHelpMessage: '是否启用该功能',
        component: 'Switch'
      },{
        field: 'yxychcd',
        label: '云溪院撤回CD',
        bottomHelpMessage: '设置撤回时间，0为不撤回',
        component: 'InputNumber',
        required: false,
        componentProps: {
          min: 0,
          max: 120,
          placeholder: '请设置时长'
        }
      },{
        field: 'chuochuo',
        label: '戳一戳',
        bottomHelpMessage: '是否启用该功能',
        component: 'Switch'
      },{
        field: 'chuorecord',
        label: '戳一戳语音',
        bottomHelpMessage: '是否启用该功能',
        component: 'Switch'
      },{
        field: 'chuochuoapi',
        label: '戳一戳接口',
        bottomHelpMessage: '是否启用该功能',
        component: 'Switch'
      },{
        field: 'pluscd',
        label: '小月PlusCD',
        bottomHelpMessage: '设置CD时间，0为无CD',
        component: 'InputNumber',
        required: false,
        componentProps: {
          min: 0,
          max: 86400,
          placeholder: '请设置时长'
        }
      },{
        field: 'plususer',
        label: '小月Plus用户源',
        bottomHelpMessage: '是否使用用户资源',
        component: 'Switch'
      },{
        field: 'defaulthelp',
        label: '小月帮助作为默认帮助',
        bottomHelpMessage: '是否使用小月帮助作为默认帮助',
        component: 'Switch'
      },{
        field: 'jiexi',
        label: '小月视频解析',
        bottomHelpMessage: '是否解析抖音短视频',
        component: 'Switch'
      }],

      getConfigData () {
        return Config.xyss
      },
      setConfigData (data, { Result }) {
        for (let [keyPath, value] of Object.entries(data)) {
          Config.modify("xyss", keyPath, value)
        }
        return Result.ok({}, '保存成功~')
      }
    }
  }
}